package cn.iocoder.yudao.module.wine.controller.app.memberdeadline;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.wine.controller.app.memberdeadline.vo.AppMemberDeadlineRespVO;
import cn.iocoder.yudao.module.wine.dal.dataobject.memberdeadline.MemberDeadlineDO;
import cn.iocoder.yudao.module.wine.service.memberdeadline.MemberDeadlineService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "App  - 会员期限")
@RestController
@RequestMapping("/wine/member-deadline")
@Validated
public class AppMemberDeadlineController {

    @Resource
    private MemberDeadlineService memberDeadlineService;


    @GetMapping("/get")
    @Operation(summary = "获得会员期限")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    @PreAuthorize("@ss.hasPermission('wine:member-deadline:query')")
    public CommonResult<AppMemberDeadlineRespVO> getMemberDeadline(@RequestParam("id") Long id) {
        MemberDeadlineDO memberDeadline = memberDeadlineService.appGetMemberDeadline(id);
        return success(BeanUtils.toBean(memberDeadline, AppMemberDeadlineRespVO.class));
    }


}
